home *** CD-ROM | disk | FTP | other *** search
-
- //
- // Description:
- // Model-view example class. Defines a simple property window which allows
- // the user to modify the center attribute of the selected sphere objects.
- //
- // Super class:
- // oops/r3window.js
- //
- // Constructor:
- // obj = new mySpherePropWin(tag list);
- //
- //
-
- include("oops/r3window.js");
- include("oops/r3packer.js");
- include("real/objects/r3sphere.js");
- include("real/gadget/r3vectg.js");
-
- // callback method which will be called by our model object
- // whenever the status of the model is changed
-
- function myUPDATE(value, id, event)
- {
- if(event == 0 ||
- event == R3OLAYM_SELECTOBJ ||
- event == R3PRIMM_TRANSFORM ||
- event == R3SPHA_Center) {
- if(this.model) {
- this.model.LOCKSHARED(0);
- obj = this.model.GETFIRSTSELECTED();
- this.model.RELEASE(0);
- if(obj) {
- if(obj.ISOFKIND(R3CLID_SPHERE)) {
- center = obj.GetCenter();
- if(center) {
- this.center.SetConflict(FALSE);
- this.center.SetValue(center);
- }
- else
- this.center.SetConflict(FALSE);
- }
- else
- this.center.SetConflict(TRUE);
- }
- else {
- this.center.SetConflict(TRUE);
- }
- }
- else this.center.SetConflict(TRUE);
- }
- }
-
- // catch the close window event and detach the model
-
- function mySpherePropWinHook(obj, method, val)
- {
- if(method == R3WM_CLOSEWINDOW) {
- obj.SetModel(0);
- obj.center.SetUnitConverter(0);
- return 1; // yes, close
- }
- return 1;
- }
-
- // callback for the center field, this allows the user to
- // modify the center
-
- function mySphereSetCenterHook(obj, event, value)
- {
- this.model.SETONSELECTED([R3SPHA_Center, value]);
- }
-
- // a method which allows the user to set our model
-
- function mySetModel(model)
- {
- if(this.model) // detach from current
- this.model.REMOVEDEPENDENT(this);
- this.model = model;
- if(this.model) // attach to new
- this.model.ADDDEPENDENT(0, 0, this);
- mySphereSetCenterHook.model = model; // tell the hook were to find the model
- this.UPDATE(0, 0, 0); // full update
- }
-
- // constructor
-
- function mySpherePropWin()
- {
- // call super class
- if(arguments.length == 0)
- return;
-
- this.model = 0;
- this.base = r3Window;
- this.base(R3WA_ReportNewSize, TRUE,
- R3WA_ReportCloseWindow, TRUE,
- R3WA_Title, "Sphere Property Window",
- R3RA_Hook, mySpherePropWinHook,
- arguments);
-
- // define methods
- this.UPDATE = myUPDATE;
- this.SetModel = mySetModel;
-
- // define user interface
- this.packer = new r3Packer(R3PA_Orientation, R3PAOF_VERTICAL);
-
- this.center = new r3Vectorgadget(R3WGA_Parent, this,
- R3GA_Text, "Center",
- R3RA_Hook, mySphereSetCenterHook);
-
- // set unitconverter, vector gaget needs it
- this.center.SetUnitConverter(GetJS("CurrentProject.UnitConverter"));
-
- this.packer.ADD(R3PAPF_FILLX, 0, this.center);
- this.SetGmanager(this.packer);
- }
-
- mySpherePropWin.prototype=new r3Window;
-